package com.huangpeng.designmodel.adapter;

import java.util.Objects;

/**
 * @Author huangpeng
 * @Title 多媒体播放适配器
 * @Package
 * @Date 2020/10/23 17:55
 * @Description 多媒体播放适配器实现了多媒体播放
 * @Version 1.0
 */
public class MediaAdapter implements MediaPlayer {
    protected AdvancedMediaPlayer advancedMediaPlayer;

    public MediaAdapter(String  audioType) {
        if(Objects.equals("vlc",audioType)){
            advancedMediaPlayer = new VlcPlayer();
        }else if(Objects.equals("mp4",audioType)){
            advancedMediaPlayer = new Mp4Player();
        }
    }

    @Override
    public void play(String audioType, String fileName) {
        if(Objects.equals("vlc",audioType)){
            advancedMediaPlayer.playVlc(fileName);
        }else if(Objects.equals("mp4",audioType)){
            advancedMediaPlayer.playMp4(fileName);
        }
    }
}
